Skip to content

HIP: Fix host-only constructors#1801

Merged
ax3l merged 5 commits intoopenPMD:devfrom
franzpoeschel:fix-hipcc-compiler-bug-2
Dec 2, 2025
Merged

HIP: Fix host-only constructors#1801
ax3l merged 5 commits intoopenPMD:devfrom
franzpoeschel:fix-hipcc-compiler-bug-2

Conversation

@franzpoeschel
Copy link
Copy Markdown
Contributor

@franzpoeschel franzpoeschel commented Nov 6, 2025

Declaring default constructors seems to make HIP compilers treat them as __host__ __device__ by default. This explicitly annotates the offending constructors as __host__.

Reverts #1754 which worked around the same problem by pulling the constructors into headers.
Fixes #1797.

TODO:

  • Comment: Rocm versions

@ax3l
Copy link
Copy Markdown
Member

ax3l commented Nov 10, 2025

Thank you, @franzpoeschel ! Were you able to reproduce/test this or do you need my help verifying the fix?

Comment thread src/backend/BaseRecord.cpp Outdated
Comment on lines +59 to +61
#ifdef __HIPCC__
__host__
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in other files but UniquePtrWithLambda seem a bit excessive to me.

Are you sure that fixing UniquePtrWithLambda, which is the only one deriving from UniquePtrWithLambda : public std::unique_ptr, ain't sufficient as a work-around?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but your original issue was related to these iterators, I see #1754

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They appear a bit excessive since they revert another workaround (just putting the offending code into headers) and now apply a better slution. The second commit is the "actual" PR.

Comment thread src/auxiliary/UniquePtr.cpp Outdated
@franzpoeschel
Copy link
Copy Markdown
Contributor Author

Thank you, @franzpoeschel ! Were you able to reproduce/test this or do you need my help verifying the fix?

I was able to reproduce the issue on Frontier, I'll look up the compiler versions, but don't my key at hand right now for checking the build.

Comment thread src/snapshots/RandomAccessIterator.cpp Outdated
Comment thread src/snapshots/RandomAccessIterator.cpp Outdated
Comment thread src/backend/BaseRecord.cpp Outdated
@franzpoeschel franzpoeschel force-pushed the fix-hipcc-compiler-bug-2 branch from db970a2 to 7a719b7 Compare November 21, 2025 12:04
Comment thread src/snapshots/RandomAccessIterator.cpp
Comment thread src/snapshots/RandomAccessIterator.cpp
@ax3l ax3l enabled auto-merge (squash) December 2, 2025 18:54
@ax3l ax3l merged commit e248cc7 into openPMD:dev Dec 2, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HIP build fails: UniquePtr.cpp:68:25: error: reference to __host__ function '~unique_ptr' in __host__ __device__ function

2 participants